/**
 * Created by Sarah on 05/02/14.
 */

function ballObject(x, y) {
    this.actualX = 0;
    this.actualY = 0;

    this.centerX = x;
    this.centerY = y;

    this.angle = 0;
    //this.velocityX = 0;//-5 + Math.random() * 10;
    //this.velocityY = 0;//-5 + Math.random() * 10;
}

ballObject.prototype.updateBall = function () {

    this.offsetX = Math.sin(this.angle);
    this.offsetY = Math.cos(this.angle);

    this.actualX = this.centerX + this.offsetX * 110;
    this.actualY = this.centerY + this.offsetY * 110;

    this.angle += .02;

    this.centerX+=0.15;

    /*
     this.distanceToTargetX = (this.targetX - this.actualX);
     this.distanceToTargetY = (this.targetY - this.actualY);

     this.overallDistanceToTarget = Math.sqrt(this.distanceToTargetX * this.distanceToTargetX + this.distanceToTargetY * this.distanceToTargetY);
     if (this.overallDistanceToTarget < 1) this.overallDistanceToTarget = 1;

     this.stepX = 2 * (this.distanceToTargetX / this.overallDistanceToTarget);
     this.stepY = 2 * (this.distanceToTargetY / this.overallDistanceToTarget);

     this.velocityStepX = (this.stepX - this.velocityX) / 100;
     this.velocityStepY = (this.stepY - this.velocityY) / 100;

     this.velocityX += this.velocityStepX;
     this.velocityY += this.velocityStepY;

     this.actualX += this.velocityX;
     this.actualY += this.velocityY;

     if (((Math.abs(this.targetX - this.actualX) < 5) && (Math.abs(this.targetY - this.actualY) < 5))) {
     this.targetX = Math.random() * Xsize - Xcenter;
     this.targetY = Math.random() * Ysize - Ycenter;
     //saveImage();
     }
     */
}
